<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class MainController extends AdminbaseController {
	
    public function index(){
    	
    	$mysql= M()->query("select VERSION() as version");
    	$mysql=$mysql[0]['version'];
    	$mysql=empty($mysql)?L('UNKNOWN'):$mysql;
    	
    	//server infomaions
    	$info = array(
    			L('OPERATING_SYSTEM') => PHP_OS,
    			L('OPERATING_ENVIRONMENT') => $_SERVER["SERVER_SOFTWARE"],
    	        L('PHP_VERSION') => PHP_VERSION,
    			L('PHP_RUN_MODE') => php_sapi_name(),
				L('PHP_VERSION') => phpversion(),
    			L('MYSQL_VERSION') =>$mysql,
    			L('PROGRAM_VERSION') => THINKCMF_VERSION . "&nbsp;&nbsp;&nbsp; ",
    			L('UPLOAD_MAX_FILESIZE') => ini_get('upload_max_filesize'),
    			L('MAX_EXECUTION_TIME') => ini_get('max_execution_time') . "s",
    			L('DISK_FREE_SPACE') => round((@disk_free_space(".") / (1024 * 1024)), 2) . 'M',
    	);

        $firstday = date('Y-m-01',strtotime(date("Y-m-d")));
        $lastday = date('Y-m-d',strtotime("$firstday +1 month -1 day"));
        $condMemberMonth['reg_time'] = array('between',array(strtotime($firstday),strtotime($lastday)));
        $resMemberMonth = D('member')->where($condMemberMonth)->count();
        $resMember = D('member')->count();
        $condOrder['status'] = array('not in','0,11,50');
        $resOrder = D('order')->where($condOrder)->count();
        $array = array(
            'member_month' => $resMemberMonth,
            'member' => $resMember,
            'order' => $resOrder,
        );

        $this->assign('count',$array);
    	$this->assign('server_info', $info);
    	$this->display();
    }
}